package com.ccq.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.ccq.domain.Result;
import com.ccq.domain.User;
import com.ccq.service.UserService;
import com.ccq.util.ResultUtil;

@RestController
public class UserController {
	
	@Autowired
	private UserService userService;
	@GetMapping("/user")
	public Result<User> getUser() {
		return ResultUtil.success(userService.findByName("zgf"));
	}

	@GetMapping("/userInsert/{name}/{age}")
	public int insertUser(@PathVariable String name, @PathVariable String age) {
		return userService.insert(name, Integer.parseInt(age));
	}

	@GetMapping("/userSt")
	public Result<User> selectUser() {
		int i=1/0;
		return ResultUtil.success(userService.selectById(2));
//		return ResultUtil.erro(null);
	}
}
